<html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">
dt {
  font-style: italic;
  margin-top: 15px;
  margin-bottom: 3px;
  margin-left: 0px;
  border-bottom: 1px dotted black;
}
dd {
  margin-left: 10px;
}
table {
  border-collapse:collapse;
  border: 1px solid black;
  margin-top: 7px;
}
th {
  border: 1px solid black;
  padding: 3 7 3 7;
}
td {
  border: 1px solid black;
  padding: 3 7 3 7;
}
</style></head><body><p><a name="getstatic"></a><b>getstatic</b> :
  get value of static field : <a href="opcodes.html">index</a> : <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitFieldInsn(int,%20java.lang.String,%20java.lang.String,%20java.lang.String)">visitFieldInsn()</a></p><dl><dt>Description</dt><dd>getstatic pops <i xmlns="">objectref</i> (a reference to an object) from
the stack, retrieves the value of the static field (also known as a class
field) identified by &lt;field-spec&gt; from <i xmlns="">objectref</i>, and pushes the
one-word or two-word value onto the operand stack. <br></br>For example, when you write the Java expression:<br></br><pre>
    PrintStream obj = java.lang.System.out;
</pre>
this
generates a call to getstatic like:<br></br><pre>
    getstatic java/lang/System/out Ljava/io/PrintStream;
    astore_1   ; store the object reference result in local variable 1
</pre>
In
Jasmin, getstatic takes two parameters, &lt;field-spec&gt; and
&lt;descriptor&gt;. &lt;field-spec&gt; provides <i xmlns="">classname</i>, the name of
the class that defines the static field, as well <i xmlns="">fieldname</i>, as the name
of the field. In the example above, the &lt;field-spec&gt; is
"java/lang/System/out", indicating that the <i xmlns="">classname</i> is
"java/lang/System" and the <i xmlns="">fieldname</i> is "out".  &lt;descriptor&gt;
indicates the type of data held in the field, and is a standard Java type
descriptor (see Chapter 4). In the example above, &lt;descriptor&gt; is
"Ljava/io/PrintStream;", i.e. a reference to a PrintStream object.<br></br>getstatic first resolves <i xmlns="">classname</i> into a Java class. Then it
locates the <i xmlns="">fieldname</i> in that class, determining the <i xmlns="">width</i> of the
field (in bytes) and its <i xmlns="">offset</i> (in bytes) from the base of the class's
static data. The type of the field must match &lt;descriptor&gt;. See Chapter 7
for more on how fields are resolved<br></br>To retrieve the value for the field, getstatic obtains the bytes
starting at <i xmlns="">offset</i> and extending for <i xmlns="">width</i> bytes from the start
of the class's static  data, expands it to either a 4-byte or 8-byte value, and
pushes the value onto the operand stack.</dd><dt>Notes</dt><dd>Fields cannot be overriden, although they can be 'shadowed'. For
example, with the two classes:<br></br><pre>
    class A { static int x; }
and
    class B extends A { static int x; }
</pre>
then
the runtime system will allocate storage for both the static field "A/x" and
the static field "B/x". Which field is accessed is determined by the class name
given in &lt;field-spec&gt;.</dd><dt>See also</dt><dd><a href="ref-putfield.html">putfield</a> <a href="ref-.html"></a> <a href="ref-getfield.html">getfield</a> <a href="ref-.html"></a> <a href="ref-putstatic.html">putstatic</a> </dd><dt>Stack</dt><dd><table xmlns="">
<tr>
<td>
<b>Before </b>
</td>
<td><b>After</b></td></tr>
<tr>
<td>...</td>
<td>value</td></tr>
<tr>
<td></td>
<td>...</td></tr>
</table></dd><dt>Bytecode</dt><dd><table xmlns="">
<tr>
<td>
<b> Type </b>
</td>
<td><b>Description</b></td></tr>
<tr>
<td>
u1 
</td>
<td>getstatic
opcode = 0xB2 (178)
</td></tr>
<tr>
<td>
u2 
</td>
<td>index</td></tr>
</table></dd></dl></body></html>